---
title: PdfHelper
summary: API reference for PdfHelper.
status: draft
owner: SAIF Doc Gen
last_reviewed: 2026-09-17
library: PdfAPI.SyncFusionCore
reference_type: package
---

# PdfHelper

`PdfHelper` is a static utility type providing three unrelated helpers used across the library and by the consuming `PdfAPI` application: AcroForm field detection, form flattening, and construction of a standardized `ApplicationExceptionDetail` diagnostic record for logging caught exceptions.

## Purpose
- Detect whether a PDF has AcroForm fields present
  ([BR-SFC-034](../../business-rules.md#br-sfc-034-form-fields-detected-by-non-null-form)).
- Flatten a PDF's form fields to make them non-editable, when a form is present
  ([BR-SFC-035](../../business-rules.md#br-sfc-035-flatten-makes-fields-non-editable), [BR-SFC-036](../../business-rules.md#br-sfc-036-flatten-without-form-returns-input-unchanged)).
- Build a standardized `ApplicationExceptionDetail` record from a caught exception, always
  attributing it to the `PdfApi` application ([BR-SFC-037](../../business-rules.md#br-sfc-037-exception-detail-attributed-to-pdfapi), [BR-SFC-038](../../business-rules.md#br-sfc-038-exception-detail-captures-diagnostic-context)).

## Context
- Namespace: `PdfAPI.SyncFusionCore`
- Assembly/package: `PdfAPI.SyncFusionCore` (`Pdf.Local.Client` NuGet package)

## Public members
| Member | Signature | Purpose |
| --- | --- | --- |
| HasFormFields | `static bool HasFormFields(byte[] pdf)` | Executes [Inspect and flatten PDF form fields](../../operations/inspect-and-flatten-pdf-form-fields.md) (OP-SFC-013) detection step: loads the bytes as a `PdfLoadedDocument` and returns whether `doc.Form` is non-null. |
| Flatten | `static byte[] Flatten(byte[] inputPdf)` | Executes [Inspect and flatten PDF form fields](../../operations/inspect-and-flatten-pdf-form-fields.md) (OP-SFC-013) flatten step: when the loaded document has a non-null `Form`, sets `Form.Flatten = true`, saves, and returns the new bytes; otherwise returns the input bytes unchanged. |
| GetApplicationDetail | `static ApplicationExceptionDetail GetApplicationDetail(IEnvironmentService envSvc, string page, string message, Exception ex)` | Executes [Build an application exception detail](../../operations/build-application-exception-detail.md) (OP-SFC-014): constructs a `SAIF.Core.Contracts.ApplicationExceptionDetail` with `Application = "PdfApi"`, the caller's environment/machine/user context, the supplied `page`/`message`, and `ex.GetFullFormattedException()` as `State`. |

## Behavioral notes
- `HasFormFields` and `Flatten` treat "no form present" as a normal, non-error case rather than an
  exceptional one.
- `GetApplicationDetail` performs no logging or I/O itself; it only constructs the record — the
  caller is responsible for passing it to `ILogService`.

## Constraints and usage notes
- All three members are static; this type is never instantiated.

## Related documentation
- [API reference](../index.md)
- [Operations and processes](../../operations-processes.md)
- [Business rules](../../business-rules.md)

## Sources
- `PdfApi.SyncFusionCore\PdfHelper.cs`
